/* Check JER_Make_Decoding_Matrix(). 
   reed_sol... already checked. */
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include "reed_sol-2.h"
#include "jerasure-2.h"
#include "galois-2.h"

using namespace std;

int main( int argc, char** argv )
{
	JER_Matrix *jm;
	JER_Matrix *jm2;
	JER_Bitmatrix *jbm;
	JER_Bitmatrix *jbm2;
	int i, j, tmp;
	vector <int> erased;
	int * dm_ids;

	int m = atoi( argv[1] );
	int k = atoi( argv[2] );
	int w = atoi( argv[3] );
	jm = reed_sol_vandermonde_coding_matrix( k, m, w );
	srand48(m);
	erased.resize(k+m, 0);
	for( i = 0; i < m; i++ )
	{
		tmp = lrand48() % ( k + m );
		if( erased[tmp] == 1 )
			i--;
		erased[tmp] = 1;
	}
	for( i = 0; i < k+m; i++ )
		if( erased[i] == 0 )
			fprintf( stdout, "Drive %d survived\n", i );

	jm2 = new JER_Matrix( k, k, w );
	dm_ids = (int*) malloc( sizeof( int ) * ( k + m ) );

	JER_Make_Decoding_Matrix( jm, erased, jm2, dm_ids );
	jm2->Print();

	return 0;
}
